using System;
using Iesi.Collections;

namespace DataLayer.Types
{

    public class InventoryItem : IBaseRecord
    {

        #region cTor

        public InventoryItem()
        {
        }

        #endregion

        #region Public Properties

        public virtual int Id { get; private set; }

        private string m_name;
        public virtual string Name
        {
            get
            {
                return m_name;
            }
            set
            {
                m_name = value;
            }
        }

        private string m_description;
        public virtual string Description
        {
            get
            {
                return m_description;
            }
            set
            {
                m_description = value;
            }
        }

        private string m_make;
        public virtual string Make
        {
            get
            {
                return m_make;
            }
            set
            {
                m_make = value;
            }
        }

        private string m_model;
        public virtual string Model
        {
            get
            {
                return m_model;
            }
            set
            {
                m_model = value;
            }
        }

        private string m_serial;
        public virtual string Serial
        {
            get
            {
                return m_serial;
            }
            set
            {
                m_serial = value;
            }
        }

        private string m_partNumber;
        public virtual string PartNumber
        {
            get
            {
                return m_partNumber;
            }
            set
            {
                m_partNumber = value;
            }
        }

        private DateTime m_purchaseDate;
        public virtual DateTime PurchaseDate
        {
            get
            {
                return m_purchaseDate;
            }
            set
            {
                m_purchaseDate = value;
            }
        }

//        private Vendor m_purchaseVendor;
//        public virtual Vendor PurchaseVendor
//        {
//            get
//            {
//                return m_purchaseVendor;
//            }
//            set
//            {
//                m_purchaseVendor = value;
//            }
//        }

        private decimal m_purchaseValue;
        public virtual decimal PurchaseValue
        {
            get
            {
                return m_purchaseValue;
            }
            set
            {
                m_purchaseValue = value;
            }
        }

        private decimal m_currentValue;
        public virtual decimal CurrentValue
        {
            get
            {
                return m_currentValue;
            }
            set
            {
                m_currentValue = value;
            }
        }

        private string m_notes;
        public virtual string Notes
        {
            get
            {
                return m_notes;
            }
            set
            {
                m_notes = value;
            }
        }

//        private Category category = null;
//        public virtual Category Category
//        {
//            get
//            {
//                return category;
//            }
//            set
//            {
//                category = value;
//            }
//        }

//        private ISet images = new ListSet();
//        public virtual ISet Images
//        {
//            get
//            {
//                return images;
//            }
//            set
//            {
//                images = value;
//            }
//        }

//        private Warranty warranty = null;
//        public virtual Warranty Warranty
//        {
//            get
//            {
//                return warranty;
//            }
//            set
//            {
//                warranty = value;
//            }
//        }

        #endregion

        #region IRecord Members

        public virtual void Save()
        {
            if (Id == 0)
            {
//                ((GenericRepository<InventoryItem>)RepositoryRegister.Instance.Retrieve<InventoryItem>()).Add(this);
//                OnDataChanged(new NewObjectEventArgs(this));
            }
            else
            {
//                ((GenericRepository<InventoryItem>)RepositoryRegister.Instance.Retrieve<InventoryItem>()).Update(this);
//                OnDataChanged(new ObjectUpdatedEventArgs(this));
            }
        }

        public virtual void Delete()
        {
//            ((GenericRepository<InventoryItem>)RepositoryRegister.Instance.Retrieve<InventoryItem>()).Remove(this);
//            OnDataChanged(new ObjectDeletedEventArgs(this));
        }

        public virtual void SetProperty(string name, object value)
        {
//            PropertySetter.Set(this, name, value);
        }

        public virtual event EventHandler<DataChangedEventArgs> DataChanged;
        private void OnDataChanged(DataChangedEventArgs e)
        {
            if (DataChanged == null) return;
            DataChanged(this, e);
        }

        #endregion

        #region ICloneable Members

        public virtual object Clone()
        {
            return MemberwiseClone();
        }

        #endregion
    }
}
